//
//  MyViewController.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/8.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "MyViewController.h"
#import "LoginViewController.h"
#import "MyViewModel.h"
#import "CertificationFreeViewController.h"
#import "StellCaiculatorViewController.h"
#import "OrderAllListViewController.h"
#import "MyAdressViewController.h"
#import "SetUpInforViewController.h"
#import "MyPurchaseViewController.h"
#import "FocusOnViewController.h"
#import "ShopCarViewController.h"
#import "MyWalletViewController.h"
#import "MyServiceBuyersViewController.h"
#import "OnSaleViewController.h"
#import "SoldRrderViewController.h"
#import "MyInvoiceViewController.h"
#import "MyStoreInformationViewController.h"

@interface MyViewController ()<MyRoleChangeDelegate>
@property (nonatomic,strong) MyViewModel * myViewModel;
@end

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden = YES;
    self.myViewModel = [[MyViewModel alloc] initWithViewToViewModel:self.groupedTableView theSuperView:self.view];
    self.myViewModel.delegate = self;
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.myViewModel.upDataInforSbuject sendNext:@"up"];
}

#pragma mark --- MyRoleChangeDelegate
-(void)roleDidSelectRowAtIndexPath:(NSIndexPath *)row_index{
    if (row_index.section == 3) {
        if (self.accountType == AccountType_FreeManagers) {
            self.accountType = AccountType_Ordinary;
        }else{
            self.accountType = AccountType_FreeManagers;
        }
        KPostNotification(KNotificationRoleStateChange, @(AccountType_FreeManagers))
    }
//    CertificationFreeViewController * certificationVC = [CertificationFreeViewController new];
//    [self.navigationController pushViewController:certificationVC animated:YES];
}

-(void)headerAction:(GLGWButton *)sender{
    if (sender.tag == 330) {//设置
        SetUpInforViewController * setupVC = [SetUpInforViewController new];
        [self.navigationController pushViewController:setupVC animated:YES];
    }else{//登陆
        if (self.userInforData.length>0) {
            return;
        }
        LoginViewController * loginVC = [LoginViewController new];
        [self.navigationController pushViewController:loginVC animated:YES];
    }
}

-(void)selectIndexSection:(NSIndexPath *)s_path theSelectBut:(GLGWButton *)s_but{
    switch (s_but.tag) {
        case 210:{
            if (s_path.section == 1) {//我的关注
                FocusOnViewController * focusOnVC = [FocusOnViewController new];
                [self.navigationController pushViewController:focusOnVC animated:YES];
            }else{//我的钱包
                MyWalletViewController *vc = [[MyWalletViewController alloc] init];
                [self.navigationController pushViewController:vc animated:YES];
            }
        }
            break;
        case 211:{
            if (s_path.section == 1) {//我的求购
                MyPurchaseViewController * mypurchaseVC = [MyPurchaseViewController new];
                [self.navigationController pushViewController:mypurchaseVC animated:YES];
            }else{//发票管理
                MyInvoiceViewController *vc = [MyInvoiceViewController new];
                [self.navigationController pushViewController:vc animated:YES];
            }
        }
            break;
        case 212:{
            if (s_path.section == 1) {//钢铁计算器
                StellCaiculatorViewController * stellCaiVC = [StellCaiculatorViewController new];
                [self.navigationController pushViewController:stellCaiVC animated:YES];
            }else{//地址管理
                MyAdressViewController * adressVC = [MyAdressViewController new];
                [self.navigationController pushViewController:adressVC animated:YES];
            }
            
        }
            break;
//自由经理人按钮
        case 213:{//购物车
            ShopCarViewController * shopCarVC = [ShopCarViewController new];
            [self.navigationController pushViewController:shopCarVC animated:YES];
        }
            break;
        case 214:{//我的关注
            FocusOnViewController * focusOnVc = [FocusOnViewController new];
            [self.navigationController pushViewController:focusOnVc animated:YES];
        }
            break;
        case 215:{//售出的订单
            SoldRrderViewController *vc = [SoldRrderViewController new];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 216:{//出售中的商品
            OnSaleViewController *vc = [OnSaleViewController new]; // 出售中的商品
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 217:{//我的求购
            MyPurchaseViewController * mypurchaseVC = [MyPurchaseViewController new];
            [self.navigationController pushViewController:mypurchaseVC animated:YES];
        }
            break;
        case 218:{//我的报价
            
        }
            break;
        case 219:{//我的钱包
            MyWalletViewController *vc = [[MyWalletViewController alloc] init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 220:{//发票管理
            MyInvoiceViewController *vc = [MyInvoiceViewController new];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 221:{//我服务的买家
            MyServiceBuyersViewController * serviceBuyersVC = [MyServiceBuyersViewController new];
            [self.navigationController pushViewController:serviceBuyersVC animated:YES];
        }
            break;
        case 222:{//我的店铺资料
            MyStoreInformationViewController *vc = [MyStoreInformationViewController new];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
            
        default:
            break;
    }
}

-(void)orderPushAction{
    OrderAllListViewController * orderAllVc = [OrderAllListViewController new];
    [self.navigationController pushViewController:orderAllVc animated:YES];
}

-(void)orderTypeSelectAction:(GLGWButton *)but{
    OrderAllListViewController * orderAllVc = [OrderAllListViewController new];
    orderAllVc.o_type = but.tag - 260;
    [self.navigationController pushViewController:orderAllVc animated:YES];
}

@end
